package com.github.pudding;


import com.github.pudding.config.WebConfig;
import com.github.pudding.model.Goods;
import com.github.pudding.persistence.GoodsMapper;
import com.github.pudding.service.GoodsService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author Stephen
 * @since 2018/9/14
 */
public class SpringApplication {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext rootContext = new AnnotationConfigApplicationContext();
        rootContext.register(WebConfig.class);
        rootContext.refresh();



        GoodsService goodsService = rootContext.getBean("goodsService", GoodsService.class);

        System.out.println("goodsService === " + goodsService);

        GoodsMapper goodsMapper = rootContext.getBean("goodsMapper", GoodsMapper.class);

        System.out.println("goodsMapper === " + goodsMapper);

        Goods goods = new Goods();
        goods.setGoodsName("Vivo");
        goods.setOrigin("China");
        goods.setPrice(2345.00);

        goodsService.insert(goods);
    }
}
